﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using WatiNSahi;


using WatiN.Core;
using WatiN.Core.Native;
using WatiN.Core.Logging;
using WatiN.Core.UtilityClasses;
using WatiN.Core.Properties;
using WatiN.Core.Native.Windows;
using WatiN.Core.DialogHandlers;
using WatiN.Core.Exceptions;

using WatiNSahi.Extensions;

namespace WatiNSahiTester
{
    class WatiNSahiFunctionTests : WatiNSahiTest
    {
        public void _click_test()
        {


        }

        public void _login_test_demo_web_server()
        {


            //browserType = BrowserType.FireFox;
            baseURL = "http://localhost:10000";

            _navigateTo("/demo/training/");
            _setValue(_textbox("user"), "test");
            _setValue(_password("password"), "secret");
            _click(_submit("Login"));

            _navigateTo("/demo/training/books.htm");

            _setValue(_textbox("q",_near(_row("Core Java"))), "2");
            _setValue(_textbox("q",_near(_row("Ruby for Rails"))), "1");
            _setValue(_textbox("q",_near(_row("Python Cookbook"))), "1");
            _click(_button("Add"));
            _click(_cell("Rs.200[1]"));
            _assertExists(_textbox("total"));
            _assert(_isVisible(_textbox("total")));
            _assertEqual("1150", _textbox("total").GetAttributeValue("value"));
            try
            {
                _click_no_wait(_button("Logout"));
            }
            catch (WatiNException we)
            {
                _logException("Element was not found :: "+ we.Message);
                try
                {
                    _click(_submit("Logout"));
                }
                catch(WatiNException we1)
                {
                    _logException("Element was not found. Exception Message :: " + we1.Message);
                }
            }

            _wait_for_complete();

            _wait(5000);
            

        }

        
        public void _test_extensions()
        {

            
        }

    }
}
